<include file="public:header"/>
<div class="banner1"></div>
<!-- 学员注册 -->
<div class="n_zhuce">
    <div class="n_zhuce_l">填写注册信息后，点击“注册”</div>
    <div class="n_zhuce_r"></div>
    <div class="clear"></div>
</div>
<div class="zhuce">
    <form action="{:u('passport/register')}" method="post" id="reg-form">
        <table border="0" cellspacing="0" cellpadding="0" class="zhuce1">
            <tr>
                <td>手机号<span>*</span></td>
                <td><input type="text" name="mobile" id="mobile"  class="cname" placeholder="手机号作为登录账号使用" value=""/></td>
                <td>姓名<span>*</span></td>
                <td><input type="text" name="username" id="username"  class="cname"/></td>
            </tr>
            <tr>
                <td>密码<span>*</span></td>
                <td><input type="text" name="password" id="password"  class="cname" placeholder="由6-20位英文字母、数字组成"/></td>
                <td>确认密码<span>*</span></td>
                <td><input type="text" name="confirmpass"  id="confirmpass" class="cname" placeholder="请重复输入密码"/></td>
            </tr>
            <tr>
                <td>性别</td>
                <td><input type="radio" name="sex" checked value="1" />男
                    <input type="radio" name="sex"  value="0" />
                    女</td>
                <td>家庭住址<span>*</span></td>
                <td><input type="text" name="address" id="address"  class="cname"/></td>
            </tr>
            <tr>
                <td>年龄<span>*</span></td>
                <td><input type="text" name="age" id="age"  class="cname"/></td>
                <td>身份证号<span>*</span></td>
                <td><input type="text" name="idcard" id="idcard"   class="cname"  placeholder="请填写有效且常用的联系电话"/></td>
            </tr>
            <tr>
                <td>民族</td>
                <td><input type="text" name="nation" id="nation"  class="cname"/></td>
                <td>邮箱<span>*</span></td>
                <td><input type="text" name="email" id="email"   class="cname" placeholder="请填写有效且常用的E-mail地址，用于找回密码"/></td>
            </tr>
            <tr>
                <td>健康状况</td>
                <td><input type="text" name="healthy" id="healthy"   class="cname"/></td>
                <td>特长</td>
                <td><input type="text" name="strength" id="strength"   class="cname"/></td>
            </tr>
            <tr>
                <td>农业银行账号<span>*</span></td>
                <td><input type="text" name="account"  id="account" class="cname"/></td>
                <td>开户行地址<span>*</span></td>
                <td><input type="text" name="account_addr" id="account_addr"  class="cname"/></td>
            </tr>
            <tr>
                <td>收货地址<span>*</span></td>
                <td><input type="text" name="receipt_addr" id="receipt_addr"  class="cname"/></td>
                <td>0号家长<span>*</span></td>
                <td><input type="text" name="first_f" id="first_f"   class="cname"/></td>
            </tr>
        </table>
        <p style="font-size:16px; color:#38970f;"><span>*</span>家庭成员（必填9名）</p>
        <table border="0" cellspacing="0" cellpadding="0" class="zhuce2">
            <tr>
                <td>家庭成员姓名</td>
                <td>联系电话</td>
                <td>关系</td>
                <td>性别</td>
                <td>年龄</td>
                <td>民族</td>
                <td>健康状况</td>
            </tr>
            <for start="0" end="9" name="i">
            <tr class="relation">
                <td><input type="text" name="family[{$i}][name]"   class="cname"/></td>
                <td><input type="text" name="family[{$i}][tel]"   class="cname"/></td>
                <td><input type="text" name="family[{$i}][relation]"   class="cname"/></td>
                <td><div style="height: 27px; width: 120px; border: 1px solid #278d05; margin-right: 10px;"><input type="radio" name="family[{$i}][sex]" value="1"  checked  class=""/>男 <input type="radio" name="family[{$i}][sex]" value="0"   class=""/>女 </div></td>
                <td><input type="text" name="family[{$i}][age]"   class="cname"/></td>
                <td><input type="text" name="family[{$i}][nation]"   class="cname"/></td>
                <td><input type="text" name="family[{$i}][healthy]"   class="cname"/></td>
            </tr>
                </for>
        </table>
        <div class="anniu"><input type="button" name="button" id="reg-btn" value="注 册" /></div>
    </form>
</div>
<!-- 底部 -->
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script>
    $(function(){
        $('#reg-btn').click(function(){
         if(!verify('#mobile', '请输入手机号')) return false;
         if(!verify('#username', '请输入姓名')) return false;
         if(!verify('#password', '请输入密码')) return false;
         var pass = $.trim($('#password').val())
         var confirmpass = $.trim($('#confirmpass').val())
         if(confirmpass != pass ){
             layer.tips('两次输入不一致', '#confirmpass', {tips:[2, '#3595CC']});
             $('#confirmpass').focus();
             return false;
         }
         if(!verify('#address', '请输入家庭住址')) return false;
         if(!verify('#age', '请输入年龄')) return false;
         if(isNaN($.trim($('#age').val())))
         {
             layer.tips('请输入年龄', '#age', {tips:[2, '#3595CC']});
             $('#confirmpass').focus();
             return false;
         }
         if(!verify('#idcard', '请输入身份证号')) return false;
            if(!paramsformat($.trim($('#idcard').val()),'idcard'))
            {
                layer.tips('请输入正确的身份证号码', '#idcard', {tips:[2, '#3595CC']});
                $('#idcard').focus();
                return false;
            }
            if(!verify('#email', '请输入邮件')) return false;
            if(!paramsformat($.trim($('#email').val()),'email'))
            {
                layer.tips('请输入正确的邮件账户', '#email', {tips:[2, '#3595CC']});
                $('#email').focus();
                return false;
            }
         if(!verify('#account', '请输入农业银行账号')) return false;
         if(!verify('#account_addr', '请输入开户行地址')) return false;
         if(!verify('#receipt_addr', '请输入收货地址')) return false;
         if(!verify('#first_f', '请输入0号家长')) return false;

        //亲属信息验证
            var conf = new Array();
            conf[0] = '请输入家庭成员姓名'
            conf[1] = '请输入联系电话'
            conf[2] = '请输入关系'
            conf[3] = '请输入性别'
            conf[4] = '请输入年龄'
            conf[5] = '请输入民族'
            conf[6] = '请输入健康状况'

            var object = $('.relation')
            $('input').css({border:'1px solid #278d05'})
            var flag = false
            $.each(object, function(q,item){
                var obj = $(this).find('input')
                for(var i=0; i< obj.length; i++)
                {
                    var it = obj.eq(i)
                    var val = it.val();
                    if(!val)
                    {
                        layer.msg(conf[i]);
                        it.focus();
                        it.css({border:'1px solid red'})
                        flag =true
                        return false;
                    }
                    if(i==1)
                    {
                        //手机号码验证
                        if(!paramsformat(val,'mobile'))
                        {
                            layer.msg('手机号码格式不正确');
                            it.focus();
                            it.css({border:'1px solid red'})
                            flag = true
                            return false;
                        }
                        var url = "{:u('passport/checkOtherMobile')}"
                        //重复性检测
                        var index = i;

                        $.post(url ,{mobile:val}, function(res){
                            if(!res.status){
                                layer.msg('该亲属手机号码已经使用过');
                                flag = true
                                $('input').css({border:'1px solid #278d05'})
                                obj.eq(index).css({border:'1px solid red'})
                                obj.eq(index).focus();
                                return false;
                            }
                            if(flag) return false;
                        },'json')

                    }
                    if(flag) return false;
                }

            })
            if(flag) return false;
            $.ajax({
                type:'post',
                url:$('#reg-form').attr('action'),
                data: $('#reg-form').serialize(),
                dataType:'json',
                success: function(res){
                    if(!res.status)
                    {
                        layer.msg(res.msg)
                        return false;
                    }
                    layer.msg('注册成功,您现在可以正常登录', {icon: 1}, function(){
                        window.location.href="{:U('member/center')}"
                    })

                }
            })
        })
    })
</script>

<include file="public:footer"/>